package com.imooc.mall.utils;

import com.imooc.mall.common.Constant;
import org.apache.tomcat.util.codec.binary.Base64;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import static com.imooc.mall.common.Constant.SALT;

/**
 * MD5密码加密
 */
public class MD5Utils {
    public static String getMD5(String strValue) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        return Base64.encodeBase64String(md5.digest((strValue+ SALT).getBytes()));
    }

/*    public static void main(String[] args) {
        String md5=null;
        try {
             md5 = getMD5("1234");
        }catch (Exception e){
            e.printStackTrace();
        }
        System.out.println(md5);
    }*/

}
